package io.renren.modules.storage;

import lombok.Data;

import java.util.HashMap;
import java.util.Map;


/**
 * 存储当前登录ID，在校验token时候更新
 */

public class LoginUserLocalStorage {
    /**
     * 存储当前登录用户
     */
    public volatile static Long   currentLoginUserId = null;

    /**
     * 存储当前用户学习进度位图 （每次JWT校验令牌时候修改）
     */
    public volatile static Map<Integer, String> currentLoginUserLearningProgressBitmaps = new HashMap<>();


    ///////////////////////////////////////////////////

    public synchronized static void setCurrentLoginUserId(Long userId) {
        currentLoginUserId = userId;
    }

    public synchronized static Long getCurrentLoginUserId() {
        return currentLoginUserId;
    }

    public synchronized static String getCurrentLoginUserLearningProgressBitmaps(Integer knowledgeType) {
        return currentLoginUserLearningProgressBitmaps.get(knowledgeType);
    }

    public synchronized static void setCurrentLoginUserLearningProgressBitmaps(Integer knowledgeType, String currentLoginUserLearningProgressBitmap) {
        LoginUserLocalStorage.currentLoginUserLearningProgressBitmaps.put(knowledgeType, currentLoginUserLearningProgressBitmap);
    }
}
